﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace COFE.Web
{
    public class LinkContainer : ILinkContainer
    {

        #region Constructor
        public LinkContainer(IEnumerable<LinkTemplate> templates, Dictionary<string, string> localLookupDictionary)
        {
            _links = from template in templates
                           select LinkTemplate.CreateLink(template, localLookupDictionary);
        }

        public LinkContainer(IEnumerable<Link> links)
        {
            _links = links;
        }
        #endregion

        #region Methods

        public IEnumerable<Link> GetLinks()
        {
            return _links;
        }

        public static void WriteLinks(XElement parentElement, ILinkContainer container)
        {
            Link.WriteLinks(parentElement, container.GetLinks());            
        }

        #endregion

        #region Data

        IEnumerable<Link> _links = new List<Link>();

        #endregion 
    }
}
